package com.tma.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class SlideShowActivity extends Activity implements OnClickListener {
    private ImageView mImageView;
    private SlideShow mSlideShow;
    private Button mPlayButton;
    private Button mStopButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_slide_show);

        mImageView = (ImageView) findViewById(R.id.iv_slideshow);
        mSlideShow = new SlideShow(this, mImageView);
        mPlayButton = (Button) findViewById(R.id.btn_play);
        mStopButton = (Button) findViewById(R.id.btn_stop);

        mPlayButton.setOnClickListener(this);
        mStopButton.setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_slide_show, menu);
        return true;
    }

    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.btn_play:
            mSlideShow.play();
            break;
        case R.id.btn_stop:
            mSlideShow.stop();
            break;
        default:
            break;
        }
    }
}
